package com.summer.framework.stream.controller.rest;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.summer.framework.stream.sender.UserSenderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.summer.framework.api.dto.Msg;

/**
 * @auther: 杨杰
 * @date: 2019/5/10 10:30
 * @description:
 */
@RestController
@RequestMapping("/msg")
@Slf4j
public class UserStreamController {

    @Autowired
    private UserSenderService userSender;

    @PostMapping("/send")
    @SentinelResource(value = "send")
    public boolean send(@RequestBody Msg msg) {
        try {
            return userSender.send(msg);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
